﻿using LNet;
using OestsServer.Net;

namespace OestsServer.Handlers
{
    public abstract class HandlerBase<Tclient> where Tclient : ClientChannel
    {
        /// <summary>
        /// 消息类型
        /// </summary>
        public abstract PacketKey PKey { get; }

        /// <summary>
        /// 返回数据包
        /// </summary>
        public Response ResponsePacket { get; set; }



        /// <summary>
        /// 构造函数中注册
        /// </summary>
        public HandlerBase()
        {
            ResponsePacket = new Response(PKey)
            {
                ReturnCode = ReturnCode.Success
            };
        }

        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="client"></param>
        /// <param name="ResquestPacket"></param>
        public virtual void Execute(Tclient client, Request resquestPacket)
        {
            if (client.User != null)
                ResponsePacket.RequestClientID = client.User.DBid;
            ResponsePacket.RecieveClientIDs = resquestPacket.RecieveClientIDs;
        }

    }
}
